Learning Perl by Randal L. Schwartz & brian d foy & Tom Phoenix
Author:Randal L. Schwartz & brian d foy & Tom Phoenix
Language: eng
Format: mobi, epub
Tags: COMPUTERS / Programming Languages / Perl
Publisher: O'Reilly Media
Published: 2011-06-16T16:00:00+00:00
And this loop counts from –150 to 1000 by threes:[269]
for ($i = –150; $i <= 1000; $i += 3) {
print "$i\n";
}
In fact, you could make any of the three control parts (initialization, test, or increment) empty, if you wish, but you still need the two semicolons. In this (quite unusual) example, the test is a substitution, and the increment is empty:
for ($_ = "bedrock"; s/(.)//; ) { # loops while the s/// is successful
print "One character is: $1\n";
}
The test expression (in the implied while loop) is the substitution, which returns a true value if it succeeded. In this case, the first time through the loop, the substitution removes the b from bedrock. Each iteration removes another letter. When the string is empty, the substitution will fail, and the loop is done.
If the test expression (the one between the two semicolons) is empty, it’s automatically true, making an infinite loop. But don’t make an infinite loop like this until you see how to break out of such a loop, which we’ll show later in this chapter:
for (;;) {
print "It's an infinite loop!\n";
}
Download
Learning Perl by Randal L. Schwartz & brian d foy & Tom Phoenix.epub
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(12593)
Hello! Python by Anthony Briggs(9928)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9804)
The Mikado Method by Ola Ellnestam Daniel Brolund(9787)
Dependency Injection in .NET by Mark Seemann(9348)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8310)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7772)
Grails in Action by Glen Smith Peter Ledbrook(7705)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7567)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7185)
Microservices with Go by Alexander Shuiskov(6950)
Practical Design Patterns for Java Developers by Miroslav Wengner(6866)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6811)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6425)
Angular Projects - Third Edition by Aristeidis Bampakos(6229)
The Art of Crafting User Stories by The Art of Crafting User Stories(5744)
NetSuite for Consultants - Second Edition by Peter Ries(5672)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5488)
Kotlin in Action by Dmitry Jemerov(5074)
